const { Schema, SchemaTypes } = require('../schema');
class AdminUser extends Schema {
    PropertyModelDataTemplate () {
        return {
            phone: { type: SchemaTypes.String, required: false },
            nickname: { type: SchemaTypes.String, required: true },
            avatar: { type: SchemaTypes.String, required: true, default: '' },

            username: { type: SchemaTypes.String, required: true },
            password: { type: SchemaTypes.String, required: true },
            isSuperAdmin: { type: SchemaTypes.Boolean, required: true, default: false },
            isEnable: { type: SchemaTypes.Boolean, required: false, default: true },
            roles: { type: SchemaTypes.Array, required: true },

            areaId: { type: SchemaTypes.ObjectId, required: false }
        };
    }

    async findByAccount (username, password) {
        return this.getModel().findOne({ username, password });
    }
}

module.exports = AdminUser;
